package com.AAL.DAO;

import java.util.List;

import org.hibernate.classic.Session;

import com.AAL.DAO.Interface.IEvaluationPlanAssessmentReportDAO;
import com.AAL.Model.Employee;
import com.AAL.Model.EvaluationPlanAssessmentReport;
import com.AAL.Utils.HibernateUtil;

public class EvaluationPlanAssessmentReportDAO implements
		IEvaluationPlanAssessmentReportDAO {

	@Override
	public EvaluationPlanAssessmentReport saveAndUpdateEvaluationPlanAssessmentReport(
			EvaluationPlanAssessmentReport evaluationPlanAssessmentReport) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		try {
			session.saveOrUpdate(evaluationPlanAssessmentReport);
		} catch (Exception e) {
			return null;
		}
		session.getTransaction().commit();
		return evaluationPlanAssessmentReport;
	}

	@Override
	public EvaluationPlanAssessmentReport deleteEvaluationPlanAssessmentReport(
			int evaluationPlanAssessmentReportID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		try {
			session.beginTransaction();
			EvaluationPlanAssessmentReport evaluationPlanAssessmentReport = (EvaluationPlanAssessmentReport) session
					.load(EvaluationPlanAssessmentReport.class,
							evaluationPlanAssessmentReportID);
			if (null != evaluationPlanAssessmentReport) {
				session.delete(evaluationPlanAssessmentReport);
			}
			session.getTransaction().commit();
			return evaluationPlanAssessmentReport;
		} catch (Exception e) {
			e.printStackTrace();
			session.getTransaction().rollback();
			return null;
		}
	}

	@Override
	public EvaluationPlanAssessmentReport getEvalationPlanAssessmentReport(
			int evaluationPlanAssessmentReportID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		EvaluationPlanAssessmentReport evaluationPlanAssessmentReport = (EvaluationPlanAssessmentReport) session
				.load(EvaluationPlanAssessmentReport.class,
						evaluationPlanAssessmentReportID);
		return evaluationPlanAssessmentReport;
	}

	@Override
	public List<EvaluationPlanAssessmentReport> getLstEvaluationPlanAssessmentReportByEmployee(
			Employee employee) {
		// TODO Auto-generated method stub
		return null;
	}

}
